<template>
  <div class="container">
    <div
      id="menu-icon"
      class="menu-btn"
      :class="{ 'menu-active': menuIsActive }"
      @click="toggleMenu"
    >
      <span class="plus"></span>
    </div>

    <template v-if="navigationItems.length">
      <ul id="menu" :class="{ active: menuIsActive }">
        <li
          v-for="navigationItem in navigationItems"
          :key="navigationItem.label"
        >
          <a
            :href="navigationItem.to"
            :class="[navigationItem.label, navigationItem.style]"
          >
            <span :class="navigationItem.icon"></span>
            <span class="label">{{ navigationItem.label }}</span>
          </a>
        </li>
      </ul>
    </template>
  </div>
</template>

<script>
export default {
  name: "MeunConcept",
  data() {
    return {
      menuIsActive: false,
      navigationItems: [
        {
          label: "home",
          to: "#",
          style: "left-menu-item",
          icon: "mdi mdi-home-roof",
        },
        {
          label: "about",
          to: "#",
          style: "left-menu-item",
          icon: "mdi mdi-brain",
        },
        {
          label: "code",
          to: "#",
          style: "right-menu-item",
          icon: "mdi mdi-code-json",
        },
        {
          label: "contact",
          to: "#",
          style: "right-menu-item",
          icon: "mdi mdi-at",
        },
      ],
    };
  },
  methods: {
    toggleMenu() {
      this.menuIsActive = !this.menuIsActive;
    },
  },
};
</script>

<style scoped>
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&display=swap");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #f2f2f2;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
}

ul#menu {
  align-items: center;
  background: #fff;
  border-radius: 50px;
  box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  height: 60px;
  justify-content: center;
  list-style-type: none;
  position: relative;
  overflow: hidden;
  transition: width 150ms ease-in-out 0ms;
  width: 60px;
}

ul#menu li:nth-child(2) {
  margin-right: 30px;
}

ul#menu li:nth-child(3) {
  margin-left: 30px;
}

ul#menu li a {
  color: #059cfa;
  display: flex;
  align-items: center;
  height: 60px;
  justify-content: center;
  font-size: 28px;
  margin-top: -11px;
  opacity: 0;
  transition: margin 200ms ease 0ms, opacity 100ms ease 0ms;
  width: 60px;
}

ul#menu li a::after {
  background: #059cfa;
  bottom: -5px;
  content: "";
  height: 5px;
  position: absolute;
  transition: width 200ms ease 0ms, bottom 200ms ease 0ms;
  width: 0;
}

ul#menu li a:hover::after {
  bottom: 0;
  width: 50px;
}

ul#menu li a.active {
  color: #fff;
  background: #059cfa;
}

ul#menu.active li a {
  opacity: 1;
}

ul#menu li a span.label {
  border-radius: 50px;
  color: #059cfa;
  content: "";
  display: block;
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 3px 10px;
  pointer-events: none;
  position: absolute;
  top: 31px;
}

ul#menu li a.left-menu-item {
  margin-right: -15px;
}

ul#menu.active li a.left-menu-item {
  margin-right: 0;
}

ul#menu li a.right-menu-item {
  margin-left: -15px;
}

ul#menu.active li a.right-menu-item {
  margin-left: 0;
}

ul#menu li a span {
  z-index: 1;
}

ul#menu.active {
  width: 348px;
}

#menu-icon {
  align-items: center;
  background: #fff;
  border: none;
  border-radius: 50%;
  box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  color: rgba(255, 255, 255, 1);
  display: flex;
  height: 75px;
  justify-content: center;
  position: absolute;
  transform-origin: center;
  transition: transform 400ms ease-in-out 0ms;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  width: 75px;
  z-index: 2;
}

#menu-icon.menu-active {
  box-shadow: none;
  transform: scale(0.6, 0.6);
  background: #fc8379;
}

.plus,
.plus::after {
  background: #059cfa;
  display: block;
  z-index: 2;
}

.plus {
  height: 21px;
  position: relative;
  transition: transform 200ms ease-in-out 0ms;
  width: 5px;
}

.plus::after {
  content: "";
  height: 5px;
  left: -8px;
  position: absolute;
  top: 8px;
  width: 21px;
}

#menu-icon.menu-active .plus,
#menu-icon.menu-active .plus::after {
  background: #fff;
}

#menu-icon.menu-active .plus {
  transform: rotate(135deg);
}
</style>
